<?php

	class My_Plugin_CheckBlockedIp extends Zend_Controller_Plugin_Abstract
	{
	    public function preDispatch(Zend_Controller_Request_Abstract $request)
	    {

			$module 	= $request->getModuleName();
			$controller = $request->getControllerName();
			$action 	= $request->getActionName();

			$clientIP = $_SERVER['REMOTE_ADDR'];

			$model = new Default_Model_DbTable_IpBlocking();
			$row = (object)$model->getRowByIpNumber($clientIP, date('Y-m-d H:i:s'), true);
			if (!empty($row->ip_number)) {
				//if ( ($module != 'default') && ($controller != 'error') && ($action != 'blocked') ) {
					//$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
					//$redirector->goto('blocked', 'error', 'default');

					$request->setModuleName('default')->setControllerName('error')->setActionName('blocked');
					$request->isDispatched(true);
				//}
			}
		}
	}

